"""
@Author : 合肥一元数智教育科技有限公司
@Date :  2025/6/11 14:10
@Description : 
 pymysql 实现数据的增删改操作
"""
import pymysql
from pymysql.cursors import DictCursor

"""
用户认证   user   username  password
接收用户的输入
查询数据库
给出认证的结果
"""
mysql_connection = pymysql.connect(
    host='localhost',
    port=3306,
    user='root',
    passwd='root',
    db='python2512',
    autocommit=True,  # 自动提交事务
    cursorclass=DictCursor  # 字典格式的游标
)
# 设置获取游标的格式  字典格式的游标  {}
# cursor = mysql_connection.cursor(cursor=DictCursor)
cursor = mysql_connection.cursor()
str_sql = "delete from user where id = %s"
row = cursor.execute(str_sql, (2,))
print(row)
"""
# [{},{}]
result = cursor.fetchall()
print(result)
for row in result:
    print(row)
"""

# 释放资源
cursor.close()
mysql_connection.close()
